package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}

	Redis struct {
		Addr     string
		Password string
		DB       int
	}
	AliYunSms struct {
		AccessKeyID     string
		AccessKeySecret string
	}
}

var Con AppConfig

func GetViperData() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("读取配置文件失败")
	}
	err = viper.Unmarshal(&Con)
	if err != nil {
		panic("解析配置文件失败")
	}
	fmt.Println(Con)
	fmt.Println("解析配置文件成功")
}
